<template>
  <div>
    <el-select
      v-model="id"
      :multiple="false"
      collapse-tags
      style="width: 100%"
      @change="handleChange"
      :placeholder="$t('labels.pleaseSelect')"
    >
      <el-option
        v-for="item in datas"
        :key="item.id"
        :label="item.name"
        :value="item.id"
      >
      </el-option>
    </el-select>
  </div>
</template>
<script>
import { getAllTags } from "@/api/tag";
export default {
  data() {
    return {
      datas: []
    };
  },
  model: {
    prop: "id",
    event: "change",
  },
  methods: {
    getData() {
      getAllTags().then((res) => {
        this.datas = res ? res : [];
      });
    },
    handleChange() {
      this.$emit("change", this.id);
    },
  },
  watch: {},
  mounted() {
    this.getData();
  },
  props: {
    id: {
      type: String,
    },
  },
};
</script>
